<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>任务[${task.name }]办理</title>
<script type="text/javascript">
	var t;
	$(function() {
		$.easyui.loading({ msg: "请耐心等待,正在加载..."});
		t = $("#t").tabs({
			enableConextMenu : true,
			onSelect : function() {				
				var index = t.tabs("getSelectedIndex");
				$.easyui.loading({ msg: "耐心等待，正在加载......", locale: "#t"});
				t.tabs("refresh", index);
			},
			onLoad:function(){				
				$.easyui.loaded("#t");
			}
		});
		t.tabs("add", {
			title : "任务历史信息",
			<c:if test="${not empty task}">
			href : "${ctx}/bpm/confForm/task-viewHistory?processInstanceId=${task.processInstanceId }",
			</c:if>
			<c:if test="${not empty historicTaskInstance}">
			href : "${ctx}/bpm/confForm/task-viewHistory?processInstanceId=${historicTaskInstance.processInstanceId }",
			</c:if>
			refreshable : true,
			iniframe : true,
			closable : false
		});
		<c:if test="${not empty businessFormUrl}">
		t.tabs("add", {
			title : "业务信息",
			href : "${ctx}${businessFormUrl}?taskId=${task.id}&businessKey=${businessKey}",
			refreshable : true,
			iniframe : true,
			closable : false
		});
		</c:if>
		<c:forEach items="${bpmConfFormList }" var="bcf"  varStatus="status">
			t.tabs("add", {
				<c:if test="${empty bcf.formTitle}">	
					title : "业务信息${status.index+1}",
				</c:if>
				<c:if test="${not empty bcf.formTitle}">	
					title:"${bcf.formTitle}",
				</c:if>
				href : "${ctx}${bcf.value}?taskId=${task.id}&businessKey=${businessKey}",
				refreshable : true,
				iniframe : true,
				closable : false
			});
		</c:forEach>
		<c:if test="${empty historyFlag}">
		t.tabs("add", {
			title : "[${task.name }]任务提交",
			<c:choose>
				<c:when test="${not empty viewTaskForm.formTitle}">
					href : "${ctx}/bpm/confForm/form-viewTaskForm2?taskId=${task.id }&formUrl=${viewTaskForm.formTitle}",
				</c:when>
				<c:otherwise>
					href : "${ctx}/bpm/confForm/form-viewTaskForm2?taskId=${task.id }",
				</c:otherwise>
			</c:choose>
			refreshable : true,
			iniframe : true,
			closable : false
		});
		</c:if>
	});
	$(window).load(function() { 
		setTimeout(function(){
			var index = t.tabs("getSelectedIndex");
			var flag=0;			
			for(var i=0;i<t.tabs('tabs').length;i++) {
	            if(t.tabs('getTab',i).panel('options').title.indexOf("需填写")>0){
	            	t.tabs("select",i);
	            	flag=1;
	            	break;
	            }
			}
			if(!flag){
				t.tabs("select",0);
				t.tabs("select",index);
			}
			$.easyui.loaded();
		},500)
	}); 
</script>
</head>
<body >
	<!-- <div data-options="region:'center',fit:true,border:true"> -->
		<div id="t" class="easyui-tabs" data-options="fit: true, border: false, showOption: true, enableNewTabMenu: true, enableJumpTabMenu: true"></div>
	<!-- </div>	 -->
</body>
</html>
